####Autocratic Revolving Doors####
####Roman-Gabriel Olar####
####Created on 17/02/2022####
####Last modified on 12/10/2024####
  
# Load Packages
library(ggplot2)
library(foreign)
library(lme4)
library(survival)
library(plm)
library(MASS)
library(mfx)
library(dummy)
library(prediction)
library(margins)
library(brglm)
library(psych)
library(logistf)
library(stargazer)
library(huxtable)
library(haven) 


rm(list = ls())
setwd("C:/Users/olarr/Dropbox/Papers/ARD Elites/Draft/ARD Observational/PoP/Final submission/Data")

#Import data   
FL <- read_dta("MainData_ARD_PoP.dta")
FL2 <- read_dta("MainData_ARD_PoP_CS.dta")

####APPENDIX 3####

#MODEL A6.1
model61 <- brglm(major_frev ~ prev_core + NUML_aut + prev_prestige_2 + prev_military + 
                   factor(gwf_caseid), family=binomial(link="logit"), method = "brglm.fit", p1 = T, data = FL2)
summary(model61)


#MODEL A6.2
model62 <- brglm(major_frev ~ prev_core + NUML_aut + prev_prestige_2 + prev_military + female +
                  dem_const + prev_gwf_military + prev_gwf_party + prev_gwf_personal + 
                  lrgdpopct1 + rgdpopc_1yrcht1 + litpopt1 +
                  factor(gwf_caseid), family=binomial(link="logit"), method = "brglm.fit", p1 = T, data = FL2)
summary(model62)

#MODEL A6.3
model63 <- brglm(major_frev ~ prev_core + NUML_aut + prev_prestige_2 + prev_military + 
                   factor(gwf_caseid), family=binomial(link="logit"), method = "brglm.fit", p1 = T, data = FL)
summary(model63)

#MODEL A6.4
model64 <- brglm(major_frev ~ prev_core + NUML_aut + prev_prestige_2 + prev_military + 
                   yr_t + yr_since_exit +
                   factor(gwf_caseid), family=binomial(link="logit"), method = "brglm.fit", p1 = T, data = FL)
summary(model64)#

#MODEL A6.5
model65 <- brglm(major_frev ~ prev_core + NUML_aut + prev_prestige_2 + prev_military + 
                   female +
                   dem_const + prev_gwf_military + prev_gwf_party + prev_gwf_personal + 
                   lrgdpopct1 + rgdpopc_1yrcht1 + litpopt1 +
                   yr_t + yr_since_exit +
                   factor(gwf_caseid), family=binomial(link="logit"), method = "brglm.fit", p1 = T, data = FL)
summary(model65)


### Export tables ###
stargazer(model61, type = "text", style = "default", 
          summary = TRUE, single.row = TRUE, out="elite_pmle1.doc")

stargazer(model62,  type = "text", style = "default", 
          summary = TRUE, single.row = TRUE, out="elite_pmle2.doc")

stargazer(model63, type = "text", style = "default", 
          summary = TRUE, single.row = TRUE, out="elite_pmle3.doc")

stargazer(model64, type = "text", style = "default", 
          summary = TRUE, single.row = TRUE, out="elite_pmle4.doc")

stargazer(model65, type = "text", style = "default", 
          summary = TRUE, single.row = TRUE, out="elite_pmle5.doc")


